﻿using System;
using System.Runtime.CompilerServices;

public static class TypeExtension
{
    public static string GetTypePath(this System.Type type, string separator, System.Type manuallyRoot)
    {
        string name = type.Name;
        while (((type != null) && (type != manuallyRoot)) && (type.BaseType != null))
        {
            type = type.BaseType;
            name = type.Name + separator + name;
        }
        return name;
    }

    public static bool Is(this object obj, System.Type other)
    {
        return ((obj != null) && obj.GetType().Is(other));
    }

    public static bool Is(this System.Type type, System.Type other)
    {
        if (other == null)
        {
            return false;
        }
        return other.IsAssignableFrom(type);
    }
}

